package geradatawarehouse.dao.oracle;

import geradatawarehouse.dao.abs.AbstractDAO;
import geradatawarehouse.dao.oracle.abs.OracleDAO;

import java.io.IOException;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.List;

public class AnoSemDAO extends OracleDAO {
	private static final String ANO_SEM_EJA_SQL = "anoSemEJA.sql";

	private static final String ANO_SEM_REGULAR_SQL = "anoSemRegular.sql";

	public AnoSemDAO() throws IOException {
		super();
	}

	public List<Integer> findAll(final boolean isEJA) throws IOException,
			SQLException {
		final List<Integer> lista = new ArrayList<Integer>();
		String query = null;
		if (!isEJA) {
			query = AbstractDAO.loadQueryFile(AnoSemDAO.ANO_SEM_REGULAR_SQL);
		} else {
			query = AbstractDAO.loadQueryFile(AnoSemDAO.ANO_SEM_EJA_SQL);
		}
		final ResultSet rs = this.querySelect(query);

		while (rs.next()) {
			lista.add(rs.getInt("ANOSEM"));
		}

		return lista;
	}
}
